﻿using Model.EasyUI;
using System.Collections.Generic;
using SqlHelper;
using Utils.Types;

namespace Service.EasyUI
{
    public class ProductService : Repository<Products>
    {
        public List<Products> GetProductList(Products model, int pageindex, int pagesize, out int total)
        {
            string sqlwhere = " where 1=1 ";
            if (model.Startdate != null && model.Enddate == null)
                sqlwhere += " and Startdate>'" + model.Startdate.DateTimeToString() + "'";
            else if (model.Startdate != null && model.Enddate != null)
                sqlwhere += " and Startdate BETWEEN '" + model.Startdate.DateTimeToString() + "' and '" + model.Enddate.DateTimeToString() + "'";
            if (model.Types != null)
                sqlwhere += " and Types=" + model.Types;
            return GetPagerListSQL(model, sqlwhere, pageindex, pagesize, out total, " order by ProductId ");
        }  
    }
}
